package com.googlecode.tda367.denty.core.dynamicbody;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.Fixture;

import com.googlecode.tda367.denty.constants.DynamicConstant;
import com.googlecode.tda367.denty.constants.Hit;
import com.googlecode.tda367.denty.constants.StateConstant;

public class TestBody implements DynamicBody, MoveableBody{
	private float x;
	private float y;
	public boolean isDestroyed = false;
	private boolean alive;
	
	Map<DynamicConstant, Float> dynamics;
	Map<StateConstant, Boolean> states;
	
	public TestBody(){
		this.alive=true;
		this.defineConstants();
	}
	
	private void defineConstants() {
		dynamics = new HashMap<DynamicConstant, Float>();
		states = new HashMap<StateConstant, Boolean>();
		
	}

	@Override
	public Vec2 getPosition(){
		return new Vec2(x,y);
	}

	@Override
	public Collection<Hit> getHitConstants(Fixture fixture) {
		return null;
	}
	
	public void setPosition(float x, float y){
		this.x = x;
		this.y = y;
	}
	
	@Override
	public void destroy(){
		this.isDestroyed  = true;
	}

	@Override
	public boolean isAlive() {
		return this.alive;
	}

	@Override
	public String getImagePath() {
		return null;
	}

	@Override
	public float getRotation() {
		return 0;
	}

	@Override
	public void beginContact(Fixture hitFixture, Collection<Hit> hitConstants) {
	}

	@Override
	public Vec2 getLinearVelocity() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void applyForce(Vec2 force) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void applyVelocity(Vec2 velocity) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public float getConstant(DynamicConstant dc) {
		float f = 0;
		if(this.dynamics.containsKey(dc))
			f = this.dynamics.get(dc);
		return f;
	}

	@Override
	public boolean getState(StateConstant sc) {
		boolean state = false;
		if(this.states.containsKey(sc))
			state = this.states.get(sc);
		return state;
	}

	@Override
	public void setState(StateConstant sc, boolean b) {
		if(this.states.containsKey(sc)){
			if(sc.equals(StateConstant.MOVING_LEFT))
				this.states.put(StateConstant.MOVING_RIGHT, false);
			if(sc.equals(StateConstant.MOVING_RIGHT))
				this.states.put(StateConstant.MOVING_LEFT, false);
			
			this.states.put(sc, true);	
		}
	}

	@Override
	public void endContact(Fixture hitFixture, Collection<Hit> hitConstants) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setAlive(boolean alive) {
		// TODO Auto-generated method stub
		
	}
	
	

}
